impl Solution {
    pub fn longest_palindrome(s: String) -> String {
        let mut dp:Vec<Vec<bool>>=Vec::with_capacity(s.len());
        for i in 0..s.len(){
            dp.push(Vec::<bool>::from([false].repeat(s.len())));
            dp[i][i]=true
        };
        let bs=s.as_bytes();
        let mut ans=&s[0..1];
        let mut max_len=1;
        for i in (0..bs.len()).rev(){
            for j in (i+1..bs.len()).rev(){
                if bs[i]==bs[j]&&(j-i==1||dp[i+1][j-1]){
                    dp[i][j]=true;
                    if j-i+1>max_len{
                        max_len=j-i+1;
                        ans=&s[i..j+1]
                    }
                }
            }
        };
        return  ans.to_string();
    }
}